home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows 95 / Programming Windows 95.iso / code / CHAP12 / NOTIFY.C < prev    next >
C/C++ Source or Header  |  1995-12-31  |  5KB  |  130 lines

  1. /*-----------------------------------------
  2.    NOTIFY.C -- Support notification lookup
  3.                (c) Paul Yao, 1996
  4.   -----------------------------------------*/
  5. #include <windows.h>
  6. #include <windowsx.h>
  7. #include <commctrl.h>
  8. #include <prsht.h>
  9. #include "notify.h"
  10.  
  11. CONTROLNOTIFICATIONS cnLookupTable[] =
  12.      {
  13.      NM_OUTOFMEMORY,       "NM_OUTOFMEMORY",
  14.      NM_CLICK,             "NM_CLICK",
  15.      NM_DBLCLK,            "NM_DBLCLK",
  16.      NM_RETURN,            "NM_RETURN",
  17.      NM_RCLICK,            "NM_RCLICK",
  18.      NM_RDBLCLK,           "NM_RDBLCLK",
  19.      NM_SETFOCUS,          "NM_SETFOCUS",
  20.      NM_KILLFOCUS,         "NM_KILLFOCUS",
  21.      LVN_ITEMCHANGING,     "LVN_ITEMCHANGING",
  22.      LVN_ITEMCHANGED,      "LVN_ITEMCHANGED",
  23.      LVN_INSERTITEM,       "LVN_INSERTITEM",
  24.      LVN_DELETEITEM,       "LVN_DELETEITEM",
  25.      LVN_DELETEALLITEMS,   "LVN_DELETEALLITEMS",
  26.      LVN_BEGINLABELEDITA,  "LVN_BEGINLABELEDITA",
  27.      LVN_BEGINLABELEDITW,  "LVN_BEGINLABELEDITW",
  28.      LVN_ENDLABELEDITA,    "LVN_ENDLABELEDITA",
  29.      LVN_ENDLABELEDITW,    "LVN_ENDLABELEDITW",
  30.      LVN_COLUMNCLICK,      "LVN_COLUMNCLICK",
  31.      LVN_BEGINDRAG,        "LVN_BEGINDRAG",
  32.      LVN_BEGINRDRAG,       "LVN_BEGINRDRAG",
  33.      LVN_GETDISPINFOA,     "LVN_GETDISPINFOA",
  34.      LVN_GETDISPINFOW,     "LVN_GETDISPINFOW",
  35.      LVN_SETDISPINFOA,     "LVN_SETDISPINFOA",
  36.      LVN_SETDISPINFOW,     "LVN_SETDISPINFOW",
  37.      LVN_KEYDOWN,          "LVN_KEYDOWN",
  38.      HDN_ITEMCHANGINGA,    "HDN_ITEMCHANGINGA",
  39.      HDN_ITEMCHANGINGW,    "HDN_ITEMCHANGINGW",
  40.      HDN_ITEMCHANGEDA,     "HDN_ITEMCHANGEDA",
  41.      HDN_ITEMCHANGEDW,     "HDN_ITEMCHANGEDW",
  42.      HDN_ITEMCLICKA,       "HDN_ITEMCLICKA",
  43.      HDN_ITEMCLICKW,       "HDN_ITEMCLICKW",
  44.      HDN_ITEMDBLCLICKA,    "HDN_ITEMDBLCLICKA",
  45.      HDN_ITEMDBLCLICKW,    "HDN_ITEMDBLCLICKW",
  46.      HDN_DIVIDERDBLCLICKA, "HDN_DIVIDERDBLCLICKA",
  47.      HDN_DIVIDERDBLCLICKW, "HDN_DIVIDERDBLCLICKW",
  48.      HDN_BEGINTRACKA,      "HDN_BEGINTRACKA",
  49.      HDN_BEGINTRACKW,      "HDN_BEGINTRACKW",
  50.      HDN_ENDTRACKA,        "HDN_ENDTRACKA",
  51.      HDN_ENDTRACKW,        "HDN_ENDTRACKW",
  52.      HDN_TRACKA,           "HDN_TRACKA",
  53.      HDN_TRACKW,           "HDN_TRACKW",
  54.      TVN_SELCHANGINGA,     "TVN_SELCHANGINGA",
  55.      TVN_SELCHANGINGW,     "TVN_SELCHANGINGW",
  56.      TVN_SELCHANGEDA,      "TVN_SELCHANGEDA",
  57.      TVN_SELCHANGEDW,      "TVN_SELCHANGEDW",
  58.      TVN_GETDISPINFOA,     "TVN_GETDISPINFOA",
  59.      TVN_GETDISPINFOW,     "TVN_GETDISPINFOW",
  60.      TVN_SETDISPINFOA,     "TVN_SETDISPINFOA",
  61.      TVN_SETDISPINFOW,     "TVN_SETDISPINFOW",
  62.      TVN_ITEMEXPANDINGA,   "TVN_ITEMEXPANDINGA",
  63.      TVN_ITEMEXPANDINGW,   "TVN_ITEMEXPANDINGW",
  64.      TVN_ITEMEXPANDEDA,    "TVN_ITEMEXPANDEDA",
  65.      TVN_ITEMEXPANDEDW,    "TVN_ITEMEXPANDEDW",
  66.      TVN_BEGINDRAGA,       "TVN_BEGINDRAGA",
  67.      TVN_BEGINDRAGW,       "TVN_BEGINDRAGW",
  68.      TVN_BEGINRDRAGA,      "TVN_BEGINRDRAGA",
  69.      TVN_BEGINRDRAGW,      "TVN_BEGINRDRAGW",
  70.      TVN_DELETEITEMA,      "TVN_DELETEITEMA",
  71.      TVN_DELETEITEMW,      "TVN_DELETEITEMW",
  72.      TVN_BEGINLABELEDITA,  "TVN_BEGINLABELEDITA",
  73.      TVN_BEGINLABELEDITW,  "TVN_BEGINLABELEDITW",
  74.      TVN_ENDLABELEDITA,    "TVN_ENDLABELEDITA",
  75.      TVN_ENDLABELEDITW,    "TVN_ENDLABELEDITW",
  76.      TVN_KEYDOWN,          "TVN_KEYDOWN",
  77.      TTN_NEEDTEXTA,        "TTN_NEEDTEXTA",
  78.      TTN_NEEDTEXTW,        "TTN_NEEDTEXTW",
  79.      TTN_SHOW,             "TTN_SHOW",
  80.      TTN_POP,              "TTN_POP",
  81.      TCN_KEYDOWN,          "TCN_KEYDOWN",
  82.      TCN_SELCHANGE,        "TCN_SELCHANGE",
  83.      TCN_SELCHANGING,      "TCN_SELCHANGING",
  84.      TBN_GETBUTTONINFOA,   "TBN_GETBUTTONINFOA",
  85.      TBN_GETBUTTONINFOW,   "TBN_GETBUTTONINFOW",
  86.      TBN_BEGINDRAG,        "TBN_BEGINDRAG",
  87.      TBN_ENDDRAG,          "TBN_ENDDRAG",
  88.      TBN_BEGINADJUST,      "TBN_BEGINADJUST",
  89.      TBN_ENDADJUST,        "TBN_ENDADJUST",
  90.      TBN_RESET,            "TBN_RESET",
  91.      TBN_QUERYINSERT,      "TBN_QUERYINSERT",
  92.      TBN_QUERYDELETE,      "TBN_QUERYDELETE",
  93.      TBN_TOOLBARCHANGE,    "TBN_TOOLBARCHANGE",
  94.      TBN_CUSTHELP,         "TBN_CUSTHELP",
  95.      UDN_DELTAPOS,         "UDN_DELTAPOS",
  96.      PSN_SETACTIVE,        "PSN_SETACTIVE",
  97.      PSN_KILLACTIVE,       "PSN_KILLACTIVE",
  98.      PSN_APPLY,            "PSN_APPLY",
  99.      PSN_RESET,            "PSN_RESET",
  100.      PSN_HELP,             "PSN_HELP",
  101.      PSN_WIZBACK,          "PSN_WIZBACK",
  102.      PSN_WIZNEXT,          "PSN_WIZNEXT",
  103.      PSN_WIZFINISH,        "PSN_WIZFINISH",
  104.      PSN_QUERYCANCEL,      "PSN_QUERYCANCEL"
  105.      } ;
  106.  
  107. int NOTIFY_COUNT = sizeof (cnLookupTable) / sizeof (CONTROLNOTIFICATIONS) ;
  108.  
  109. //-------------------------------------------------------------------
  110. // QueryNotifyText: Convert notification codes into text.
  111. //-------------------------------------------------------------------
  112. BOOL QueryNotifyText (UINT nNotifyCode, LPSTR *pName)
  113.      {
  114.      BOOL bFound = FALSE ;
  115.      int  iNotify ;
  116.  
  117.      for (iNotify = 0 ; iNotify < NOTIFY_COUNT ; iNotify++)
  118.           {
  119.           if (cnLookupTable[iNotify].nCode == nNotifyCode)
  120.                {
  121.                *pName = cnLookupTable[iNotify].pName ;
  122.                return TRUE ;
  123.                }
  124.           }
  125.  
  126.      // Unknown notification code.
  127.      *pName = "** Unknown **" ;
  128.      return FALSE ; 
  129.      }
  130.